<template>
  <div class="left-box">
    <div class="imgbox">
      <div class="userphoto">
        <img :src="imageUrl" alt />
      </div>
    </div>
    <div class="title">
      <div class="s-name">{{ userName }}</div>
      <div class="s-qm">{{ signature }}</div>
    </div>
    <div>
      <ul>
        <li>
          <router-link to="/home" tag="span">主页</router-link>
        </li>
        <li>
          <span @click="openlog">日志</span>
        </li>
        <li>
          <span @click="openAnount">公告</span>
        </li>
        <li>
          <router-link to="/message" tag="span">留言</router-link>
        </li>
        <li>
          <!-- <span @click="openArchive">归档</span> -->
          <router-link to="/archive" tag="span">归档</router-link>
        </li>
        <li>
          <router-link to="/musichome" tag="span">音乐</router-link>
        </li>
      </ul>
      <div class="outerlink">
        <a href="https://me.csdn.net/qq_37970097">
          <img src="https://i.loli.net/2020/03/23/MdH53Gwq9ufQkeO.png" alt />
        </a>
        <a href="https://gitee.com/ymshen">
          <img src="https://i.loli.net/2020/03/23/Y2rPBUkgLxiDIV4.png" alt />
        </a>
        <a href="https://github.com/lijinshen-ym?tab=repositories">
          <img src="https://i.loli.net/2020/03/23/iAzKYEQrO8H73bp.png" alt />
        </a>
        <a href="">
          <el-tooltip
            class="item"
            effect="light"
            content="QQ：2896583081"
            placement="bottom"
          >
            <img src="https://i.loli.net/2020/04/15/qZv8CKNW1Jx5w2L.png" alt />
          </el-tooltip>
        </a>
      </div>
    </div>
    <div class="beian">
      <a href="http://beian.miit.gov.cn/">备案号：粤ICP备19141395号</a>
    </div>
  </div>
</template>
<script>
import { FindFile } from "../api/index"
export default {
  name: "Left",
  data() {
    return {
      imageUrl: "",
      userName: "",
      signature: "",
    }
  },
  created() {
    this.getFile()
  },
  mounted() {
    this.$EventBus.$on("updateUser", this.getFile)
  },
  methods: {
    // 首页
    goHome() {
      this.$router.push({
        path: "/home",
        query: { distance: 0, page: 1 },
      })
    },
    // 打开公告，并向父组件传递数据
    openAnount() {
      this.$emit("changeDrawer", { type: "annount" })
    },
    // 打开归档，并向父组件传递数据
    openArchive() {
      this.$emit("changeDrawer", { type: "archive" })
    },
    // 获取个人信息
    getFile() {
      FindFile().then((res) => {
        this.userName = res.userName
        this.signature = res.signature
        this.imageUrl = res.photo
      })
    },
    openlog() {
      this.$emit("openDialog")
    },
  },
}
</script>
<style lang="scss" scoped>
.left-box {
  text-align: center;
  max-width: 250px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}
.left-box > div {
  width: 250px;
}
.imgbox {
  display: flex;
  justify-content: center;
}
.userphoto {
  height: 150px;
  width: 150px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: 0px;
  img {
    display: inline-block;
    object-fit: cover;
    height: 150px;
    width: 150px;
    border-radius: 50%;
  }
}

.title {
  .s-name {
    font-size: 30px;
    color: rgb(122, 124, 124) !important;
    margin-top: 20px;
  }
  .s-qm {
    color: rgb(134, 133, 133) !important;
    font-weight: normal;
    line-height: 30px;
    font-size: 16px;
    margin-top: 20px;
    margin-bottom: 10px;
  }
}
ul li {
  list-style: none;
  margin: 20px 0px;
  span {
    color: rgb(122, 119, 119);
  }
  span:hover {
    cursor: pointer;
    opacity: 0.7;
  }
}
.outerlink {
  margin-top: 40px;
  text-align: center;

  a {
    margin: 0px 10px;
    text-decoration: none;
    color: white;
    display: inline-block;
    vertical-align: middle;
    img {
      width: 25px;
      vertical-align: middle;
    }
  }
}
.beian {
  margin-top: 40px;
  a {
    color: #9a9ea0;
    text-decoration: none;
  }
}
</style>
